package com.diana.controller;

import com.diana.service.AlipayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.Map;

@RestController
public class AlipayController {

    @Autowired
    private AlipayService alipayService;

    private static final Logger log = LoggerFactory.getLogger(AlipayController.class);

    @RequestMapping("/alipay/notify")
    public String alipayNotify(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        return alipayService.alipayNotify(request,response);
    }

    @RequestMapping("/alipay/return")
    public void alipayReturn(HttpServletRequest request, HttpServletResponse response) throws Exception {
        alipayService.alipayReturn(request,response);
    }

    @RequestMapping("/admin/alipay/doAlipayCheckParam")
    public String doAlipayCheckParam(@RequestBody Map map){
        return alipayService.doAlipayCheckParam(map);
    }

    @RequestMapping("/alipay/doAlipay")
    public String doAlipay(String amount,String message){
        return alipayService.doAlipay(amount,message);
    }

    @RequestMapping("/admin//alipay/alipayRefund")
    public String alipayRefund(@RequestBody Map map){
        return alipayService.alipayRefund(map);
    }
}
